package com.ruoyi.web.controller.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.domain.Trajectory;
import com.ruoyi.web.service.ITrajectoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 轨迹信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-19
 */
@RestController
@RequestMapping("/trajectory")
public class TrajectoryController extends BaseController
{
    @Autowired
    private ITrajectoryService trajectoryService;

    /**
     * 查询轨迹信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Trajectory trajectory)
    {
        startPage();
        List<Trajectory> list = trajectoryService.selectTrajectoryList(trajectory);
        return getDataTable(list);
    }

    /**
     * 获取轨迹信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(trajectoryService.selectTrajectoryById(id));
    }

    /**
     * 新增轨迹信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody Trajectory trajectory)
    {
        return toAjax(trajectoryService.insertTrajectory(trajectory));
    }

    /**
     * 修改轨迹信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Trajectory trajectory)
    {
        return toAjax(trajectoryService.updateTrajectory(trajectory));
    }

    /**
     * 删除轨迹信息
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(trajectoryService.deleteTrajectoryByIds(ids));
    }

    /**
     * 根据订单号查询轨迹信息
     */
    @GetMapping("/getByOrderNo")
    public AjaxResult getByOrderNo(String orderNo) {
        List<Trajectory> list = trajectoryService.getByOrderNo(orderNo);
        return success(list);
    }


}
